package StringClass;

import java.util.Scanner;

public class StringTest {
    public static void main(String[] args) {
     String s ="hello";
     char c = s.charAt(0);
        System.out.println(c);//h
//        Scanner scanner = new Scanner(System.in);
//        scanner.next();
        boolean b =s.contains("llo");//是否包含  true
        System.out.println(b);
        char[] chs=s.toCharArray();
        for (int i = 0; i <chs.length ; i++) {
            System.out.print(chs[i]+"\t");

        }
        int  index   =  s.indexOf("l");//找寻首次出现的下标
        System.out.println(index);//2
        int index1 =s.lastIndexOf("o");
        System.out.println(index1);//4//找寻最后出现的下标
        String str ="aaaa aa";
        System.out.println(str.trim());//去除前后空格
        String str1 ="";
        System.out.println(str1.isEmpty());//判断字符串是否为空串
        String test="dfwffefefeweer4rrcdcxasd";
       String[] text= test.split("4");//以什么分割字符串,分隔后成数组,分割的依据会消失
        for (int i = 0; i <text.length ; i++) {
            System.out.println(text[i]);//dfwffefefeweer
            //rrcdcxasd
        }
        String substr=test.substring(8);//指定的下标开始截
        System.out.println(substr);//feweer4rrcdcxasd
        System.out.println(test.length());//24
    String substr1=test.substring(8,24);//从哪里到哪里截取字符串,左边包含右边不包含
        System.out.println(substr1);//feweer4rrcdcxasd

    }
}
